#include <stdio.h>

int asm_gcd(int x, int y)
{
    int gcd = 0;

    __asm__ (
        "mov r0, %1 \n"
        "mov r1, %2 \n"
        "gcd: \n"
        "cmp r0, r1 \n"
        "subcs r0, r0, r1 \n"
        "subcc r1, r1, r0 \n"
        "bne gcd \n"
        "mov %0, r1 \n" 
        : "=r"(gcd)
        : "r"(x),"r"(y)
        : "r0","r1"
        ); 

    printf("x = %d y = %d gcd = %d\n", x, y, gcd);

    return gcd;
}

void main()
{
    printf("gcd = %d\n",  asm_gcd(20, 12));

}
